package jdbc.day1;

import jdbc.day1.demo2_操作.Stu;
import tmp.RowMapper;
import tmp.Tmp;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

public class Test {
    public static void main(String[] args)throws Exception {
        //Tmp.update("delete from stu where s_id=?",8);
        //List<Stu>list= Tmp.query("select * from stu",new A() );
//        List<Stu>list= Tmp.query("select * from stu", new RowMapper<Stu>() {
//            @Override
//            public Stu mapRow(ResultSet rs) throws SQLException {
//                return new Stu(rs.getInt("s_id"),rs.getInt("c_id"),rs.getString("sname"),rs.getDouble("score"));
//            }
//        });
        List<Stu>list= Tmp.query("select * from stu", rs ->new Stu(rs.getInt("s_id"),rs.getInt("c_id"),rs.getString("sname"),rs.getDouble("score")));
        System.out.println(list);
    }
}
class A implements RowMapper<Stu> {

    @Override
    public Stu mapRow(ResultSet rs) throws SQLException {
        return new Stu(rs.getInt("s_id"),rs.getInt("c_id"),rs.getString("sname"),rs.getDouble("score"));
    }
}


